﻿@{
    ViewBag.Title = "便利超人";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@Styles.Render("~/Content/css/buy")
<script language="javascript" src="http://res.mail.qq.com/mmr/static/lib/js/jquery.js" type="text/javascript"></script>
<script language="javascript" src="http://res.mail.qq.com/mmr/static/lib/js/lazyloadv3.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
    loadingShow();
    // 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。
    document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
        loadingHide();
        ////公众号支付
        //jQuery('a#weixinPay').click(function (e) {
        WeixinJSBridge.invoke('getBrandWCPayRequest', {
            "appId": "@ViewBag.appId", //公众号名称，由商户传入
            "timeStamp": "@ViewBag.timeStamp", //时间戳
            "nonceStr": "@ViewBag.nonceStr", //随机串
            "package": "@ViewBag.package",//扩展包
            "signType": "MD5", //微信签名方式:MD5
            "paySign": "@ViewBag.paySign" //微信签名
        }, function (res) {
            if (res.err_msg == "get_brand_wcpay_request:ok") {
                OrderMgr.wxPayOrderSucCallback();
            } else {
                OrderMgr.wxPayOrderFailedCallback();
            }
            goOrderInfo();
        });

        //    });
    }, false);
    function goOrderInfo() {
        window.history.pushState("", "", "/UserCenter/Index");
        window.location.href = '/OrderInfo/Index';
    }
</script>

<nav class="mod_nav">
    <div class="lay_left">
        <a class="nav_back" onclick="turnBack()"><img src="/images/return_1.png" ontouchstart="replaceBackImage(this, 1)" ontouchend="replaceBackImage(this, 2)"></a>
        <span>加载微信安全支付...</span>
    </div>
</nav>

@*<div class="buyWindow">
        <section class="OrderCon">
            <section id="defaultAddress" class="OrderPartOne">
                <div class="OrderPostion" id="validDelliveryAddr">
                    <p><span id="deliveryAddrUserName"></span></p>
                    <p id="deliveryAddr"></p>
                </div>
            </section>
            <section class="OrderPartTwo">
                <div class="OrderPay">
                    <span>微信支付</span>
                    <img id="weixinPay" paytypeid="2" src="@Url.Content("~/")images/OrderPayT.png">
                </div>
            </section>
            <section class="OrderPartThree">
                <div class="GoodsListLayout">
                    <div class="goodsListDoc">
                        <table>
                            <tbody id="shoppingGoodsList"></tbody>
                        </table>
                    </div>
                </div>
            </section>
        </section>
    </div>
    <section class="Shopping">
        <section class="ShopPart4">
            <div class="ShoppingTxt fll">
                <div class="ShoppingMoney1">
                    <span>共</span><a id="ShoppingCarTotalPrice"></a>
                </div>
            </div>
            <div class="ShoppingAll flr">
                <a id="weixinPay" href="javascript:void(0);"><span>确认支付</span></a>
            </div>
        </section>
    </section>

    <script>
        window.onload = function () {
            loadDeliveryAddr();
            showShoppingGoodsList();
            showShoppingCarFee();
            setBuyWindowHeight();
        }
        function turnBack() {
            window.history.back();
        }

        function loadDeliveryAddr() {
            var deliveryAddrInfo = TerminalMgr.getTerminalInfo();
            if (null != deliveryAddrInfo) {
                $("#deliveryAddrUserName").show();
                $("#deliveryAddrUserName").text(deliveryAddrInfo.name);
                $("#deliveryAddr").text(deliveryAddrInfo.address);
            }
        }
        //配送费、总价、邮费
        function showShoppingCarFee() {
            var totalPrice = ShoppingMgr.getTotalPrice();
            $('#ShoppingCarTotalPrice').html("￥" + totalPrice.toFixed(1));

        }

        function showShoppingGoodsList() {
            var shoppingList = ShoppingMgr.getShoppingList();
            if (null != shoppingList && shoppingList.length > 0) {
                var url = '/Buy/ShowGoodsInfo';
                NativeAjax(shoppingList, url, function (msg) {
                    loadPartialViewResult(msg, $("#shoppingGoodsList"), 1);
                    $(".shopping-goods-count").remove();
                });
            }
        }
        function invalidOrderCallback() {
            //这里表示是无效订单，需要刷新商品列表
            showShoppingGoodsList();
            showShoppingCarFee();
        }
        function setBuyWindowHeight() {
            //当前浏览器窗口高度 - 购物车高度 Nav高度
            var currentWindowHeight = $(window).height() - 56 - 48;
            //当前容器确定高度
            $(".buyWindow").css("height", currentWindowHeight + "px");
        }

        function showOrderInfo(orderInfo) {

        }

    </script>*@